JavaScript ReferenceProperties
Methods [new] Socket (); Creates a new Socket object. Returns Object. close(); Terminates the open connection. The return value is true if the connection was closed, false on I/O errors. Deleting the connection has the same effect. Remember, however, that JavaScript garbage collects the object at some null time, so the connection may stay open longer than you want to if you do not close it explicitly. Returns Boolean listen (Number port [, String encoding]); Instructs the object to start listening for an incoming connection. The port argument is the TCP/IP port number where the object should listen on; typical values are 80 for a Web server, 23 for a Telnet server and so on. The encoding parameter is optional. The call to listen() is mutually exclusive to a call to open(). The result is true if the connection object successfully started listening, false otherwise. Parameters
Returns Boolean open (String computer [, String encoding]); Open the connection for subsequent read/write operations. The computer name is the name or IP address, followed by a colon and the port number to connect to. The port number is mandatory. Valid computer names are e.g. "www.adobe.com:80" or "192.150.14.12:80". The encoding parameter is optional; currently, it can be one of "ASCII", "binary" or "UTF-8". The call to open() is mutually exclusive to a call to listen(). Parameters
Returns Boolean poll(); Check a listening object for a new incoming connection. If a connection request was detected, the method returns a new Socket object that wraps the new connection. Use this connection object to communicate with the remote computer. After use, close the connection and delete the JavaScript object. If no new connection request was detected, the method returns null. Returns a new Socket object or null. read ([Number count]); Read up to the given number of characters from the connection. Returns a string that contains up to the number of characters that were supposed to be read. If no count is supplied, the connection attempts to read as many characters it can get until the remote server closes the connection or a timeout occurs. Parameters
Returns String readln(); Read one line of text up to the next line feed. Line feeds are recognized as CR, LF, CRLF or LFCR pairs. Returns String write (String text, ╔); Write the given string to the connection. The parameters of this function are concatenated to a single string. Returns true on success. Parameters
Returns Boolean writeln (String text, ╔); Write the given string to the connection and append a Line Feed character. The parameters of this function are concatenated to a single string. Returns true on success. Parameters
Returns Boolean |